cmake_minimum_required(VERSION 3.15)
project(DINGHAN_CAMERA)

#execute_process(COMMAND git clone https://gitee.com/nextpbx/mfx_dispatch.git ..)
add_definitions(-DDHVIDEO_EXPORT -D_LIB)
SET(CMAKE_BUILD_TYPE "MinSizeRel")
if(NOT CMAKE_CL_64)
add_link_options( /SAFESEH:NO)
endif()


include_directories("../mfx_dispatch")
include_directories("mfx_dispatch/include")
include_directories("mfxcom/include" "mfxcom/include/vm")
include_directories("D:/Program Files (x86)/IntelSWTools/Intel(R) Media SDK 2018 R2/Software Development Kit/include")
include_directories("D:/DH_Work/OpenSource/opencv/build/install/include")
include_directories("D:/Program Files/boost_1.72.0")
if(CMAKE_CL_64)
include_directories("D:/DH_Work/OpenSource/ffmpeg/ffmpeg64/include")
else()
include_directories("D:/DH_Work/OpenSource/ffmpeg/ffmpeg32/include")
endif()
include_directories("D:/DH_Work/OpenSource/libyuv/include")
#include_directories("D:/DH_Work/OpenSource/ffmpeg/libffmpeg/include")

set(decode_video decode_video.cpp)
set(encode_video encode_video.cpp)
set(transcode_video transcoding.cpp)
aux_source_directory(mfxcom/src common_src)
aux_source_directory(mfxcom/src/vm common_vm)
aux_source_directory(mfx_dispatch/src dispatch)
set(code DHTest.cpp DHDecode.cpp DHEncode.cpp DHVideo.cpp DHVideo.h)
    #DHMfxEncode.cpp DHMfxDecode.cpp  DHMfxEncode.h DHMfxDecode.h)

#link_directories("D:/DH_Work/OpenSource/ffmpeg/libffmpeg/lib_X64")
#link_directories("D:/Program Files (x86)/IntelSWTools/Intel(R) Media SDK 2018 R2/build/win_x64/lib")
#link_directories("D:/Program Files (x86)/IntelSWTools/Intel(R) Media SDK 2018 R2/Software Development Kit/lib/x64")
if(CMAKE_CL_64)
link_directories("D:/DH_Work/OpenSource/ffmpeg/ffmpeg64/lib")
else()
link_directories("D:/DH_Work/OpenSource/ffmpeg/ffmpeg32/lib")
endif()

if(CMAKE_CL_64)
link_directories("D:/DH_Work/OpenSource/opencv/build/install/x64/vc16/lib")
endif()

link_directories("D:/Program Files/boost_1.72.0/stage/lib")
if(CMAKE_CL_64)
link_directories("D:/DH_Work/OpenSource/libyuv/build_x64/Debug")
else()
link_directories("D:/DH_Work/OpenSource/libyuv/build/Debug")
endif()
#link_directories("D:/Program Files (x86)/Visual Leak Detector/lib/Win64")

#link_directories("D:/ProgramFiles/MSYS2/usr/local/bin")
#add_link_options(/FORCE:MULTIPLE)

add_library(DHVideo2 SHARED ${code} ${common_src} ${common_vm} ${dispatch})
add_executable(DHVideo3 ${code} ${common_src} ${common_vm} ${dispatch})
target_link_libraries(DHVideo3 avcodec.lib avfilter.lib avformat.lib avutil.lib swscale.lib swresample.lib avdevice.lib
    opencv_core440d.lib opencv_imgproc440d.lib opencv_imgcodecs440d.lib opencv_photo440d.lib 
    libboost_thread-vc120-mt-gd-x64-1_72.lib 
    dxva2.lib d3d9.lib d3d11.lib dxgi.lib
    yuv.lib)
target_link_libraries(DHVideo2 avcodec.lib avfilter.lib avformat.lib avutil.lib swscale.lib swresample.lib avdevice.lib
    libboost_thread-vc120-mt-gd-x64-1_72.lib 
    dxva2.lib d3d9.lib d3d11.lib dxgi.lib
    yuv.lib)